<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
  <title>Document</title>
  <script src="js/vue.min.js">
  </script>
</head>
<body>

<div id="app">
  <script src="https://video.sdk.qcloudecdn.com/web/TXLivePusher-2.1.1.min.js" charset="utf-8"></script>
  <div id="local_video" style="width:100%;height:500px;display:flex;align-items:center;justify-content:center;"></div>

  <button @click="openCamera">开启摄像头</button>
  <button @click="openMicrophone">开启麦克风</button>
  <button @click="closeCamera">关闭摄像头</button>
  <button @click="closeMicrophone">关闭麦克风</button>
  <button @click="startPush">开启直播</button>
  <button @click="closePush">关闭直播</button>
</div>
<script>
  new Vue({
    el:"#app",
    data:{
      livePusher:null
    },
    methods:{
      openCamera(){
        livePusher.startCamera();
      },
      openMicrophone(){
        this.livePusher.startMicrophone();
      },
      closeCamera(){
        this.livePusher.stopCamera();
      },
      closeMicrophone(){
        this.livePusher.stopMicrophone();
      },
      startPush(){
        this.livePusher.startPush('webrtc://duxiaonan.zhengyisky.com/pinxixi/huawei?txSecret=xxx&txTime=xxx');
      },
      closePush(){
        this.livePusher.stopPush();
      },
    },
    created(){
      this.livePusher = new TXLivePusher();
      this.livePusher.setRenderView('local_video');
      this.livePusher.videoView.muted = true;
      // 设置视频质量
      this.livePusher.setVideoQuality('720p');
      // 设置音频质量
      this.livePusher.setAudioQuality('standard');
      // 自定义设置帧率
      this.livePusher.setProperty('setVideoFPS', 25);
    }
  })
</script>

</body>
</html>